package xkp.lesson2;

public class MyClass {
    private Integer count = 0;

    //当多个线程访问同一个MyClass对象时才生效
/*
    public synchronized void addCount(){
        count++;
    }
*/

    public  void addCount(){
        synchronized (this) {
            count++;
        }
    }

    public  Integer getCount(){
        return count;
    }
}
